using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace Modules.Gate
{
    /*
     * GateManager 管理所有门的状态
     */
    public class GateManager : MonoBehaviour
    {
        [SerializeField]
        private List<GateAgent> gates;



        private void Start()
        {
            foreach (GateAgent gate in gates)
            {
                gate.Init();
            }
        }
        public GateAgent FindGateByLabel(string label)
        {
            GateAgent gateAgent = gates.Find(g => g.Label.Equals(label, StringComparison.OrdinalIgnoreCase));
            return gateAgent;
        }

        public GateAgent[] FindGatesByLabel(params string[] labels)
        {
            return gates.Where(g => labels.Contains(g.Label)).ToArray();
        }

        public GateAgent[] FindGatesByGroup(string group)
        {
            return gates.Where(g => g.Group.Equals(group)).ToArray();
        }

        public GateAgent[] GetAll()
        {
            return gates.ToArray();
        }

    }
}